from utils.database import db

class Problem(db.Model):
    __tablename__ = 'oj_table'

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    title = db.Column(db.String(50))
    level = db.Column(db.String(50))
    description = db.Column(db.String(4096))
    templateCode = db.Column(db.String(4096))
    testCode = db.Column(db.String(4096))

    def __init__(self, title, level, description, templateCode, testCode):
        self.title = title
        self.level = level
        self.description = description
        self.templateCode = templateCode
        self.testCode = testCode

    def to_dict(self):
        return {
            'id': self.id,
            'title': self.title,
            'level': self.level,
            'description': self.description,
            'templateCode': self.templateCode,
            'testCode': self.testCode
        }

    def to_simple_dict(self):
        return {
            'id': self.id,
            'title': self.title,
            'level': self.level
        }